//
//  YDFundDetailsTopView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/14.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDFundDetailsTopView.h"

@interface YDFundDetailsTopView()
//背景图片
@property (nonatomic , weak) UIImageView *backImage;
@property (nonatomic , weak) UIView *Vline1;//分割线

//标题label
@property (nonatomic , weak) UILabel *label1;//可用金额
@property (nonatomic , weak) UILabel *label2;//冻结


//金额数值
@property (nonatomic , weak) UILabel *labelN1;//可用金额（元）
@property (nonatomic , weak) UILabel *labelN2;//冻结（元）

@end


@implementation YDFundDetailsTopView

-(void)setDict:(NSDictionary *)dict
{
    _dict = dict;
    if (!dict) {
        return;
    }else{
        
        /*
         id : 11,
         availableBalance : 87910,
         updateTime : 2017-12-03 14:56:13,
         publisherId : 11,
         publisherSerialCode : 821f6a1a-52db-427a-82bb-2e97bdc0fdff,
         frozenCapital : 12000,
         balance : 99910
         */
        //可用金额
        NSString *availableBalance = [NSString stringWithFormat:@"%@",dict[@"availableBalance"]];
        //冻结金额
        NSString *frozenCapital = [NSString stringWithFormat:@"%@",dict[@"frozenCapital"]];
        
        if ([availableBalance floatValue] == 0) {
            self.labelN1.text = @"0.00";
        }else{
            self.labelN1.text = [NSString countNumAndChangeformat:[availableBalance pz_stringNumberByMultiplyingBy:@"1"]];
            
        }
        
        if ([frozenCapital floatValue] == 0) {
            self.labelN2.text = @"0.00";
        }else{
           self.labelN2.text = [NSString countNumAndChangeformat:[frozenCapital pz_stringNumberByMultiplyingBy:@"1"]];
        }
        
        
    }
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self backImage];
        
        [self Vline1];
        
        [self label1];
        [self label2];
        [self labelN1];
        [self labelN2];
        
    }
    return self;
}

+(instancetype)fundDetailsTopViewWithAccountDict:(NSDictionary *)dict
{
    
    YDFundDetailsTopView *topView = [[self alloc] init];
    topView.dict = dict;
    return topView;
}

-(UIImageView *)backImage
{
    if (_backImage == nil) {
        UIImageView *backImage = [[UIImageView alloc] init];
        [self addSubview:backImage];
        backImage.backgroundColor = [UIColor clearColor];
        backImage.image = [UIImage imageNamed:@"wd-jianbian"];
        [backImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.equalTo(self);
        }];
        
        _backImage = backImage;
    }
    return _backImage;
}
-(UIView *)Vline1
{
    if (_Vline1 == nil) {
        UIView *Vline1 = [[UIView alloc] init];
        [self addSubview:Vline1];
        Vline1.backgroundColor = NumberColor(247, 247, 247);
        [Vline1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@1);
            make.centerX.equalTo(self);
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(103));
                make.height.equalTo(@(rateX812(40)));
            }else{
                make.height.equalTo(@(rate750(40)));
                make.top.equalTo(self).offset(rate750(83));
            }
        }];
        
        _Vline1 = Vline1;
    }
    return _Vline1;
}

-(UILabel *)label1
{
    if (_label1 == nil) {
        UILabel *label1 = [[UILabel alloc] init];
        [self addSubview:label1];// 173 179 193
        label1.textAlignment = NSTextAlignmentCenter;
        label1.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        label1.textColor = [UIColor whiteColor];
        label1.text = @"可用金额 (元)";
        [label1  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.mas_centerX).offset(-rate375(57));
            make.top.equalTo(self.Vline1.mas_top);
        }];
        
        _label1 = label1;
    }
    return _label1;
}
-(UILabel *)label2
{
    if (_label2 == nil) {
        UILabel *label2 = [[UILabel alloc] init];
        [self addSubview:label2];// 173 179 193
        label2.textAlignment = NSTextAlignmentCenter;
        label2.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        label2.textColor = [UIColor whiteColor];
        label2.text = @"冻结 (元)";
        [label2  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_centerX).offset(rate375(57));
            make.top.equalTo(self.Vline1.mas_top);
        }];
        
        _label2 = label2;
    }
    return _label2;
}

-(UILabel *)labelN1
{
    if (_labelN1 == nil) {
        UILabel *labelN1 = [[UILabel alloc] init];
        [self addSubview:labelN1];// 173 179 193
        labelN1.textAlignment = NSTextAlignmentCenter;
        labelN1.font = [UIFont systemFontOfSize:font18ScreenWRate * LKScreenW];
        labelN1.textColor = [UIColor whiteColor];
        labelN1.text = @"----";
        [labelN1  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.label1);
            if (isPhoneX) {
                make.top.equalTo(self.label1.mas_bottom).offset(rateX812(3));
            }else{
                make.top.equalTo(self.label1.mas_bottom).offset(rate750(3));
            }
        }];
        
        _labelN1 = labelN1;
    }
    return _labelN1;
}
-(UILabel *)labelN2
{
    if (_labelN2 == nil) {
        UILabel *labelN2 = [[UILabel alloc] init];
        [self addSubview:labelN2];// 173 179 193
        labelN2.textAlignment = NSTextAlignmentCenter;
        labelN2.font = [UIFont systemFontOfSize:font18ScreenWRate * LKScreenW];
        labelN2.textColor = [UIColor whiteColor];
        labelN2.text = @"----";
        [labelN2  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.label2);
            if (isPhoneX) {
                make.top.equalTo(self.label2.mas_bottom).offset(rateX812(3));
            }else{
                make.top.equalTo(self.label2.mas_bottom).offset(rate750(3));
            }
        }];
        
        _labelN2 = labelN2;
    }
    return _labelN2;
}





@end
